//
//  ComposeViewController.swift
//  elarc01
//
//  Created by elarc on 16/4/15.
//  Copyright © 2016年 elarc. All rights reserved.
//

import Foundation

class ComposeViewController:ElarcPopViewController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        
        
        let popView = UIView()
        popView.frame = CGRectMake(0, UIScreen.mainScreen().bounds.size.height, UIScreen.mainScreen().bounds.size.width, UIScreen.mainScreen().bounds.size.height / 2.0)
        popView.backgroundColor = UIColor.grayColor()
        
        //加个阴影
        
        popView.layer.shadowColor = UIColor.blackColor().CGColor
        popView.layer.shadowOffset = CGSizeMake(0.5, 0.5);
        popView.layer.shadowOpacity = 0.8;
        popView.layer.shadowRadius = 5;
        
        //导航栏一定要加载ROOTVC上面
        let elarcPopRoot = ElarcPopRootViewController()
        elarcPopRoot.title = "我去"
        let nav = UINavigationController(rootViewController: elarcPopRoot)
        
        //关闭btn
        let closeBtn = UIButton(type:.Custom)
        closeBtn.frame = CGRectMake(15, 0, 50, 40);
        closeBtn.setTitle("关闭", forState: .Normal)
        closeBtn.setTitleColor(UIColor.blackColor(), forState: .Normal)
        closeBtn.addTarget(self, action: #selector(close), forControlEvents: UIControlEvents.TouchUpInside)
        popView.addSubview(closeBtn)
        
        //开启btn
        
        let openBtn = UIButton(type:.Custom)
        openBtn.frame = CGRectMake((self.view.frame.size.width - 100)/2.0, 300, 100, 40);
        openBtn.setTitle("开启", forState: .Normal)
        openBtn.setTitleColor(UIColor.blackColor(), forState: .Normal)
        openBtn.addTarget(self, action: #selector(show), forControlEvents: UIControlEvents.TouchUpInside)
        elarcPopRoot.view.addSubview(openBtn)
        
        createPopVCWithRootVC(nav, popView:popView)
        
        showBackIcon()
    }
    
    func showBackIcon(){
    let backBtn = UIButton(type: UIButtonType.Custom)
    backBtn.setImage(UIImage(named: "tabbar_profile_dev"), forState: .Normal)
    backBtn.setImage(UIImage(named: "tabbar_profile_dev"), forState:  .Highlighted)
    backBtn.addTarget(self, action: #selector(ComposeViewController.leftpushTo), forControlEvents: .TouchUpInside)
    backBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignment.Left
    backBtn.contentEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 0)
    backBtn.frame = CGRectMake(0, 0, 10, 18)
    
    self.navigationItem.leftBarButtonItem =  UIBarButtonItem(customView: backBtn);
    }
    
    func leftpushTo(){
     self.navigationController?.dismissViewControllerAnimated(true, completion: {
     })
    }
    
}